<template>
  <div>
    <div v-for="(basicInfo,index) in basicInfos" :key="index" >
      <el-form :model="basicInfo" :inline="true">
        <!-- <el-form-item label="总里程：">
           {{basicInfo.totalDistance}}
        </el-form-item> -->
        <el-form-item label="总里程：">
          <el-input v-model="basicInfo.totalDistance"></el-input>
        </el-form-item>
        <el-form-item label="行驶时间">
          <el-input v-model="basicInfo.totalTime"></el-input>
        </el-form-item>
        <el-form-item label="平均速度">
          {{parseInt(basicInfo.totalDistance/(basicInfo.totalTime/60))}}
        </el-form-item>
        <el-form-item label="夜间车速">
          <el-input v-model="basicInfo.nightSpeed"></el-input>
        </el-form-item>
        <el-form-item label="夜间时长">
          <el-input v-model="basicInfo.nightTime"></el-input>
        </el-form-item>
        <el-form-item label="连续时长">
          <el-input v-model="basicInfo.continueTime"></el-input>
        </el-form-item>
        <span style="line-height:40px;">{{formatDate(basicInfo.time, 'yyyy/MM/dd')}}</span>
         <el-button type="primary" @click="onSubmit(basicInfo)">修改</el-button>
      </el-form>
    </div>
  </div>
</template>

<script>
import { listInfo, editInfo } from '@/apis/basicInfo'
import {formatDate} from '@/utils/date.js'
export default {
  created () {
    listInfo().then(e => {
      this.basicInfos = e.data
    })
  },
  methods: {
    formatDate,
    onSubmit (basicInfo) {
      basicInfo.time = formatDate(basicInfo.time, 'yyyy-MM-dd')
      basicInfo.avgSpeed = parseInt(basicInfo.totalDistance / (basicInfo.totalTime / 60))
      editInfo(basicInfo).then(e => {
        this.$message('修改成功')
      })
    }
  },
  data () {
    return {
      basicInfos: []
    }
  },
  name: 'editInfo'
}
</script>

<style scoped>

</style>


